﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace QuanLyThuoc.DAL
{
   public class NhapThuocDAL:KetNoiDAL
    {
       public DataTable SelectAll_ThuocNhap()
       {
           SqlCommand cmd = new SqlCommand("SelectAll_ThuocNhap",Connect());
           cmd.CommandType = CommandType.StoredProcedure;
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataTable dt = new DataTable();
           da.Fill(dt);
           return dt;
       }
       public DataTable SelectID_NhapThuoc(string IDPN)
       {
           SqlCommand cmd = new SqlCommand("SelectID_ThuocNhap", Connect());
           cmd.CommandType = CommandType.StoredProcedure;
           cmd.Parameters.AddWithValue("@IDPN", IDPN);
           SqlDataAdapter da = new SqlDataAdapter(cmd);
           DataTable dt = new DataTable();
           da.Fill(dt);
           return dt;
       }
       public int InsertNhapThuoc(string IDPN, string ctp, string TenThuoc, int IDThuoc, string DVtMua, string Dvt, decimal HeSoQD, int SL_N, int GiaNhap, int ThanhTien, DateTime NgaySX, DateTime HanDate)
       {
           
               SqlCommand cmd = new SqlCommand("Insert_ThuocNhap", Connect());
               cmd.CommandType = CommandType.StoredProcedure;
               cmd.Parameters.AddWithValue("@IDPN", IDPN);
               cmd.Parameters.AddWithValue("@IDCT", ctp);
               cmd.Parameters.AddWithValue("@IDThuoc", IDThuoc);
               cmd.Parameters.AddWithValue("@TenThuoc", TenThuoc);
               cmd.Parameters.AddWithValue("@DvtMua", DVtMua);
               cmd.Parameters.AddWithValue("Dvt", Dvt);
               cmd.Parameters.AddWithValue("@HeSoQD", HeSoQD);
               
               cmd.Parameters.AddWithValue("@SL_N", SL_N);
               cmd.Parameters.AddWithValue("@GiaNhap", GiaNhap);
               cmd.Parameters.AddWithValue("@ThanhTien", ThanhTien);
               cmd.Parameters.AddWithValue("NgaySX", NgaySX);
               cmd.Parameters.AddWithValue("@HanDate", HanDate);
             return  cmd.ExecuteNonQuery();
           

       }
       public int UpdateNhapThuoc(string IDPN, string Stt, int IDThuoc, string TenThuoc, string DVtMua, string Dvt, decimal HeSoQD, string SLNhap, string SL_N, int GiaNhap, int ThanhTien, DateTime NgaySX, DateTime HanDate)
       {
          
               SqlCommand cmd = new SqlCommand("Update_ThuocNhap", Connect());
               cmd.CommandType = CommandType.StoredProcedure;
               cmd.Parameters.AddWithValue("@IDPN", IDPN);
               cmd.Parameters.AddWithValue("@Stt", Stt);
               cmd.Parameters.AddWithValue("@IDThuoc", IDThuoc);
               cmd.Parameters.AddWithValue("@TenThuoc", TenThuoc);
               cmd.Parameters.AddWithValue("@DvtMua", DVtMua);
               cmd.Parameters.AddWithValue("Dvt", Dvt);
               cmd.Parameters.AddWithValue("@HeSoQD", HeSoQD);
               cmd.Parameters.AddWithValue("@SLNhap", SLNhap);
               cmd.Parameters.AddWithValue("@SL_N", SL_N);
               cmd.Parameters.AddWithValue("@GiaNhap", GiaNhap);
               cmd.Parameters.AddWithValue("@ThanhTien", ThanhTien);
               cmd.Parameters.AddWithValue("NgaySX", NgaySX);
               cmd.Parameters.AddWithValue("@HanDate", HanDate);
             return  cmd.ExecuteNonQuery();
           
       }
       public int DeleteNhapThuoc(string IDPN)
       {
          
               SqlCommand cmd = new SqlCommand("Delete_ThuocNhap", Connect());
               cmd.CommandType = CommandType.StoredProcedure;
               cmd.Parameters.AddWithValue("@IDPN", IDPN);
             return  cmd.ExecuteNonQuery();
        
       }
    }
}
